package service.impl;

import common.Constants.ServiceConstant;
import common.Result;
import common.Util.MD5Util;
import dao.UserDao;
import dataBean.UserDo;
import service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by lxl on 2015/10/30.
 */
@Deprecated
public class LoginServiceImpl implements LoginService {

    @Autowired
    private UserDao userDao ;

    @Override
    public Result login(UserDo userDo) {

        Result result = new Result() ;

        String password  = userDao.selectUserByUsername(userDo.getUsername()).getPassword() ;

        if( MD5Util.toMD5(userDo.getPassword()) == password ){

            result.setSucces(true);
            result.addParam("token",MD5Util.toMD5(userDo.getUsername()));

        }else {

            result.setSucces(false);
            result.setError(ServiceConstant.LOGIN_ERROR);

        }

        return result;
    }
}
